<?php

Yii::import('usuarios.models._base.BaseTCargoav');

class TCargoav extends BaseTCargoav {

    /**
     * @return TCargoav
     */
    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public static function label($n = 1) {
        return Yii::t('app', 'TCargoav|TCargoavs', $n);
    }

    /**
     * Metodo en l cual obtenemos unicamente los cargos disponibles para esta persona
     * y q aun no ha escogido.
     * @param type $per_id
     * @return type
     */
    public function getCargosAppPersona($per_id) {
//    SELECT * FROM t_cargoav tcaav
//where tcaav.est_id ="1" and  tcaav.cav_id not in (Select tem.cav_id from t_empleado tem where tem.per_id=1500 and tem.cav_id!="null");

        $command = Yii::app()->db->createCommand()
                ->select("*")
                ->from("t_cargoav tcaav")
                ->where("tcaav.est_id =:est_id AND tcaav.cav_id not in (Select tem.cav_id from t_empleado tem where tem.per_id=:per_id and tem.cav_id!='null')");
        $command->bindValues(array(
            ':per_id' => $per_id,
            ':est_id' => "1",
        ));
        $command->order("tcapp.cap_descripcion");
        $result = $command->queryAll();
        return ($result);
    }

}
